/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.koller.million.card.frame.item;

import de.koller.million.card.engine.item.Item;
import java.awt.Color;
import java.awt.Point;

/**
 *
 * @author User
 */
public class ItemSlotPanel extends javax.swing.JPanel {

	private Item item = null;
	/**
	 * Creates new form ItemSlotPanel
	 */
	public ItemSlotPanel() {
		initComponents();
	}

	public Item getItem() {
		return item;
	}

	public void setItem( Item item ) {
		this.item = item;
		
		if( item == null )
			this.setBackground( new Color( 0xff000000 ) );
		else
			this.setBackground( item.getQualityColor() );
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBackground(new java.awt.Color(255, 204, 255));
        setPreferredSize(new java.awt.Dimension(25, 25));
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                formMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                formMouseExited(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 25, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 25, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

	private void formMouseEntered( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_formMouseEntered
		ItemToolTip.SINGLE.showItem( item );
		
		Point p = this.getLocationOnScreen();
		ItemToolTip.SINGLE.setLocation( (int)p.getX() + this.getWidth() + 3,
										(int)p.getY() + this.getHeight() + 3 );
	}//GEN-LAST:event_formMouseEntered

	private void formMouseExited( java.awt.event.MouseEvent evt ) {//GEN-FIRST:event_formMouseExited
		ItemToolTip.SINGLE.unshow();
	}//GEN-LAST:event_formMouseExited

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
